package com.gui.components.indexTabel;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.constants.PlaceOfDiviness;
import com.utils.ResourcesLoader;

public class IndexTableCellRenderer extends JLabel implements TableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = -239634737658467953L;

	ImageIcon madinahIcon=ResourcesLoader.getImageIcon("/com/data/images/madinah.jpg");
	ImageIcon kabahIcon=ResourcesLoader.getImageIcon("/com/data/images/kabah.jpg");
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		
		//this.setEnabled(false);
		//int fontStyle=this.getFont().getStyle();
		String fontName=this.getFont().getName();
		Font font=new Font(fontName,Font.BOLD,17 );
		this.setFont(font);

		this.setHorizontalAlignment(JLabel.CENTER);
		this.setHorizontalTextPosition(JLabel.LEFT);
		
		if(isSelected)
		{
		this.setForeground(Color.BLUE);
		}
		else
		{
			this.setForeground(Color.black);
		}
		if(value.equals(PlaceOfDiviness.MADINAH))
		{
			this.setText(PlaceOfDiviness.madinahName);
			this.setIcon(madinahIcon);
			
			
		}
		else
			if(value.equals(PlaceOfDiviness.MAKKAH))
			{
				this.setText(PlaceOfDiviness.makahName);
				this.setIcon(this.kabahIcon);
			}
			else
			{
				this.setText(value.toString());
				this.setIcon(null);
			}
		
		return this;
	}

}
